/**
 * Created by 121 on 2016/4/08.
 */
require.config(require_config);

define([
    'jquery',
    'common',
    'ready',
    'template',
    'calendar'
], function( $, common,ready,template,calendar) {

    console.log('login');
    var main = function() {
        this.init();console.log('login');
    };

    main.prototype = {
        init: function() {
            this.event();
        },

        event: function() {
            var _this = this;
            $('.form_datetime').calendar();
            $.ajax({
                url:'/data_report_page',
                type: 'get',
                data:{name:name},
                success: function (res) {
                    if(res.code==0){
                        $('#date').html(template('date_tpl', {'date': res.date}));
                        $('#data-list').html(template('data-item', {'data': res.data}));
                    }else{
                        Alert({'msg':'报表不存在',type:'error'});
                    }
                }

            });
            //按时间查询
            $('#btn-search').on('click', function (e) {
                e.preventDefault();
                var date =$('input[name="date"]').val();
                $.ajax({
                    url: '/data_report_page',
                    type: 'get',
                    data:{date:date,name:name},
                    success: function (res) {
                        $('#date').html(template('date_tpl', {'date': res.date}));
                        $('#data-list').html(template('data-item', {'data': res.data}));
                    }
                });
            });
        }

    };

    (new main());

});
